package com.ruoyi.sys.garden.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.sys.garden.entity.TbRecruitmentRelease;
import com.ruoyi.sys.garden.service.ITbRecruitmentReleaseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招聘发布Controller
 * 
 * @author jinsuo
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/system/release")
public class TbRecruitmentReleaseController extends BaseController
{
    @Autowired
    private ITbRecruitmentReleaseService tbRecruitmentReleaseService;

    /**
     * 查询招聘发布列表
     */
    @PreAuthorize("@ss.hasPermi('system:release:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbRecruitmentRelease tbRecruitmentRelease)
    {
        startPage();
        List<TbRecruitmentRelease> list = tbRecruitmentReleaseService.selectTbRecruitmentReleaseList(tbRecruitmentRelease);
        return getDataTable(list);
    }

    /**
     * 导出招聘发布列表
     */
    @PreAuthorize("@ss.hasPermi('system:release:export')")
    @Log(title = "招聘发布", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbRecruitmentRelease tbRecruitmentRelease)
    {
        List<TbRecruitmentRelease> list = tbRecruitmentReleaseService.selectTbRecruitmentReleaseList(tbRecruitmentRelease);
        ExcelUtil<TbRecruitmentRelease> util = new ExcelUtil<TbRecruitmentRelease>(TbRecruitmentRelease.class);
        util.exportExcel(response, list, "招聘发布数据");
    }

    /**
     * 获取招聘发布详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:release:query')")
    @GetMapping(value = "/{rrId}")
    public AjaxResult getInfo(@PathVariable("rrId") Long rrId)
    {
        return AjaxResult.success(tbRecruitmentReleaseService.selectTbRecruitmentReleaseByRrId(rrId));
    }

    /**
     * 新增招聘发布
     */
    @PreAuthorize("@ss.hasPermi('system:release:add')")
    @Log(title = "招聘发布", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbRecruitmentRelease tbRecruitmentRelease)
    {
        return toAjax(tbRecruitmentReleaseService.insertTbRecruitmentRelease(tbRecruitmentRelease));
    }

    /**
     * 修改招聘发布
     */
    @PreAuthorize("@ss.hasPermi('system:release:edit')")
    @Log(title = "招聘发布", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbRecruitmentRelease tbRecruitmentRelease)
    {
        return toAjax(tbRecruitmentReleaseService.updateTbRecruitmentRelease(tbRecruitmentRelease));
    }

    /**
     * 删除招聘发布
     */
    @PreAuthorize("@ss.hasPermi('system:release:remove')")
    @Log(title = "招聘发布", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rrIds}")
    public AjaxResult remove(@PathVariable Long[] rrIds)
    {
        return toAjax(tbRecruitmentReleaseService.deleteTbRecruitmentReleaseByRrIds(rrIds));
    }
}
